package com.project.service.proxy;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * cglib实现动态代理
 */
public class LogCglibInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println(method.getName() + " cglib start -->");
        Object result = methodProxy.invokeSuper(o, objects);
        System.out.println(method.getName() + " cglib end -->");
        return result;
    }
}
